//useful functions I need

module("ers", package.seeall)

//players
function GetPlayerList()
	local res = {}
	for k, ply in pairs(player.GetAll()) do
		res[ply:Name()] = ply
	end
	return res
end

function GetPlayerByName(name)
	return GetPlayerList()[name]
end

function GetNoclippedPlayers()
	local res = {}
	for k, ply in pairs(player.GetAll()) do
		if ply:GetMoveType() == MOVETYPE_NOCLIP then
			res[ply] = true
		end
	end
	
	return res
end
//====================================================

//util
function MatchString(str, tbl)
	local strlen = string.len(str)
	
	local matches = {}
	for k, v in pairs(tbl) do
		if string.sub(str, 1, strlen) == string.sub(k, 1, strlen) then
			table.insert(matches, k)
		end
	end
	return matches
end

function ConcatOntoTableValues(str, tbl)
	for k, v in pairs(tbl) do
		tbl[k] = str .. v
	end
	return tbl
end
//====================================================

